package com.langll.ai.portfolio.mapper;

import com.langll.ai.portfolio.model.PortfolioProduct;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author langll2
 * @since 2025-04-09
 */
@Mapper
public interface PortfolioProductMapper extends BaseMapper<PortfolioProduct> {

    /**
     * 获取所有的 FiscalYear FY AA/AA+1 , planning_cycle & LIFECYCLE_EXTEND_TO
     *
     * @return
     */
    @Select("select DISTINCT t.FiscalYear from (select pp.PLANNING_CYCLE as FiscalYear from portfolio_product pp group by pp.PLANNING_CYCLE  UNION select pp.LIFECYCLE_EXTEND_TO as FiscalYear from portfolio_product pp group by pp.LIFECYCLE_EXTEND_TO) t where t.FiscalYear is not null and t.FiscalYear != \"\" order by t.FiscalYear desc")
    public List<String> getAllFiscalYear();
}
